package com.emailsystem.emailsystem.exception;

/**
 * 自定义异常处理
 */
public class MailException extends RuntimeException {

    // 异常状态码
    private final Integer code;
    // 异常信息
    private final String message;

    // 构造异常
    public MailException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    // 使用异常枚举构造异常
    public MailException(MailExceptionEnum exceptionEnum) {
        this(exceptionEnum.getCode(), exceptionEnum.getMsg());
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
